//
//  FeedbackController.m
//  WuJieLive
//
//  Created by 张瀚坤 on 2017/11/1.
//  Copyright © 2017年 zhk. All rights reserved.
//

#import "FeedbackController.h"

@interface FeedbackController ()

@end

@implementation FeedbackController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

-(void)setNavi
{
    self.title = @"意见反馈";
}

-(void)setUI
{
    self.view.backgroundColor = Color(245, 245, 245);
    NSArray * array = @[self.btnOne,self.btnTwo,self.btnThree,self.btnFour,self.btnFive];
    for ( int i = 0; i < array.count; i ++) {
        ((UIButton *)array[i]).layer.masksToBounds = YES;
        ((UIButton *)array[i]).layer.cornerRadius = 15;
        ((UIButton *)array[i]).layer.borderColor = ColorWithHexString(@"666666").CGColor;
        ((UIButton *)array[i]).layer.borderWidth = 0.5;
        [((UIButton *)array[i]) setTitleColor:MainColor forState:(UIControlStateSelected)];
        
        [((UIButton *)array[i]) addTarget:self action:@selector(changeStatus:) forControlEvents:(UIControlEventTouchUpInside)];
    }
    
}

- (void)changeStatus:(UIButton *)sender
{
    sender.selected = !sender.isSelected;
    sender.layer.borderColor = sender.selected ? MainColor.CGColor : ColorWithHexString(@"666666").CGColor;
//    if (sender.selected) {
//
//    }
}

- (IBAction)commitBtn:(id)sender {
    if (self.textView.text.length) {
        [MBProgressHUD showHUDAddedTo:self.view animated:YES];
        NSDictionary * dict = @{@"token":self.userToken,@"feedback_contents":self.textView.text};
        [HTTPTool POSTForm:[NSString stringWithFormat:@"%@help-center/feedback",BaseUrl] para:dict success:^(BOOL isSuccess, id responseObject) {
            [MBProgressHUD hideHUDForView:self.view animated:YES];
            if (isSuccess) {
                [MBProgressHUD showSuccess:@"提交成功"];
                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                    [self.navigationController popToRootViewControllerAnimated:YES];
                });
            }
        } failure:^(NSError *error) {
            [MBProgressHUD hideHUDForView:self.view animated:YES];
        }];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
